﻿using System.Windows;

namespace StudentInfoSystem.UI.Views.Dialogs
{
    public partial class DeleteConfirmationDialog : Window
    {
        public bool DontAskAgain { get; private set; }
        public bool IsConfirmed { get; private set; }

        public DeleteConfirmationDialog(string message)
        {
            InitializeComponent();
            MessageText.Text = message;
        }

        private void ConfirmButton_Click(object sender, RoutedEventArgs e)
        {
            DontAskAgain = DontAskAgainCheckBox.IsChecked ?? false;
            IsConfirmed = true;
            DialogResult = true;
            Close();
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            IsConfirmed = false;
            DialogResult = false;
            Close();
        }

        private void CloseButton_Click(object sender, RoutedEventArgs e)
        {
            IsConfirmed = false;
            DialogResult = false;
            Close();
        }

        public static (bool confirmed, bool dontAskAgain) ShowDialog(string message, Window owner)
        {
            var dialog = new DeleteConfirmationDialog(message)
            {
                Owner = owner,
                WindowStartupLocation = WindowStartupLocation.CenterOwner
            };

            var result = dialog.ShowDialog();
            return (dialog.IsConfirmed, dialog.DontAskAgain);
        }
    }
}